﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Easyleave.Service;
using Easyleave.Workflow;
using Easyleave.Logic;

namespace Easyleave.ServiceHost
{
    class Program
    {
        static void Main(string[] args)
        {
            //create workflow service
            System.ServiceModel.ServiceHost workflowServiceHost = new System.ServiceModel.ServiceHost(typeof(LeaveWorkflowService));
            WfWcfExtension wfWcfExtension = new WfWcfExtension(EasyleaveConstants.CONFIG_SECTION_NAME);
            workflowServiceHost.Extensions.Add(wfWcfExtension);
            workflowServiceHost.Open();
            Console.WriteLine("The 'LeaveWorkflowService' is ready.");
            Console.WriteLine();

            //create membership service
            System.ServiceModel.ServiceHost membershipServiceHost = new System.ServiceModel.ServiceHost(typeof(MembershipService));
            membershipServiceHost.Open();
            Console.WriteLine("The 'MemebershipService' is ready.");
            Console.WriteLine();

            //cleanup
            Console.WriteLine("Press <ENTER> to terminate service.");
            Console.WriteLine();
            Console.ReadLine();
            workflowServiceHost.Close();
            membershipServiceHost.Close();

            //using (System.ServiceModel.ServiceHost serviceHost = new System.ServiceModel.ServiceHost(service))
            //{
            //    // Instantiate and add the extension which hosts our workflow runtime

            //    WfWcfExtension wfWcfExtension =
            //        new WfWcfExtension("EasyleaveWorkflow");

            //    serviceHost.Extensions.Add(wfWcfExtension);
            //    serviceHost.Open();

            //    // We use Console.ReadLine() to block this thread so that the host
            //    // instances remains open. Service calls are recieved and processed on
            //    // background threads.

            //    Console.WriteLine("The LeaveService WCF  is ready.");
            //    Console.WriteLine("Press <ENTER> to terminate service.");
            //    Console.WriteLine();
            //    Console.ReadLine();

            //    serviceHost.Close();
            //}
        }

    }
}
